package com.vip.seata.at.order.controller;

import com.vip.seata.at.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    //使用Seata
    @PostMapping("create")
    public String create(String userId, String commodityCode, int count) throws InterruptedException {
        orderService.create(userId, commodityCode,count);
        return "success";
    }

//    //不使用Seata的
//    @PostMapping("createNoSeata")
//    public String createNoSeata(Order order) {
//        orderService.createNoSeata(order);
//        return "success";
//    }
//
//    // 在另一个微服务里再调用feign
//    @PostMapping("create2")
//    public String create2(Order order) {
//        orderService.create2(order);
//        return "success";
//    }
}
